<div class="content">
    <div id="example_title">
        <h1>Show/Hide Columns</h1>
        There are a number of useful functions to work with columns. You can add, remove, show, hide, find columns with these methods. The
        grid below shows an example how to toggle columns.
    </div>
    <div id="example_view"></div>
    <div id="example_code"></div>
</div>

<!--CODE-->
<div id="grid" style="width: 800px; height: 400px;"></div>
<br>
<button class="w2ui-btn" onclick="action('hideColumn', 'lname');">Hide First Column</button>
<button class="w2ui-btn" onclick="action('showColumn', 'lname');">Show First Column</button>
<span style="padding: 10px; color: silver">|</span>
<button class="w2ui-btn" onclick="action('toggleColumn', 'lname');">Toggle First Column</button>
<button class="w2ui-btn" onclick="action('toggleColumn', 'sdate');">Toggle Last Column</button>

<!--CODE-->
<script type="module">
import { w2grid } from '__W2UI_PATH__'

let grid = new w2grid({
    name: 'grid',
    box: '#grid',
    show: { footer: true },
    columns: [
        { field: 'lname', text: 'Last Name', size: '150px' },
        { field: 'fname', text: 'First Name', size: '150px' },
        { field: 'email', text: 'Email', size: '100%' },
        { field: 'sdate', text: 'Start Date', size: '90px' }
    ],
    records: [
        { recid: 1, fname: 'Jane', lname: 'Doe', email: 'jdoe@gmail.com', sdate: '4/3/2012' },
        { recid: 2, fname: 'Stuart', lname: 'Motzart', email: 'jdoe@gmail.com', sdate: '4/3/2012' },
        { recid: 3, fname: 'Jin', lname: 'Franson', email: 'jdoe@gmail.com', sdate: '4/3/2012' },
        { recid: 4, fname: 'Susan', lname: 'Ottie', email: 'jdoe@gmail.com', sdate: '4/3/2012' },
        { recid: 5, fname: 'Kelly', lname: 'Silver', email: 'jdoe@gmail.com', sdate: '4/3/2012' },
        { recid: 6, fname: 'Francis', lname: 'Gatos', email: 'jdoe@gmail.com', sdate: '4/3/2012' },
        { recid: 7, fname: 'Mark', lname: 'Welldo', email: 'jdoe@gmail.com', sdate: '4/3/2012' },
        { recid: 8, fname: 'Thomas', lname: 'Bahh', email: 'jdoe@gmail.com', sdate: '4/3/2012' }
    ]
})

window.action = function (method, param) {
    grid[method](param)
}
</script>
